#include "../include/Condition.hpp"
#include "../include/MutexLock.hpp"

namespace cdm{

Condition::Condition(MutexLock& mutex)
:_cond(),
_mutex(mutex){
    pthread_cond_init(&_cond,NULL);
}

Condition::~Condition(){
    pthread_cond_destroy(&_cond);
}

void Condition::wait(){
    pthread_cond_wait(&_cond,_mutex.getMutexPtr());
}

void Condition::notifyOne(){
    pthread_cond_signal(&_cond);
}

void Condition::notifyAll(){
    pthread_cond_broadcast(&_cond);
}


}//end of namespace


